package DAO;

import Utils.JdbcUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class EmpDeleteDaoImpl implements EmpDeleteDao {
    /**
     * 通过id删除数据
     *
     * @param id
     */
    private Connection connection = null;
    private PreparedStatement statement = null;

    @Override
    public void EmpDeleteById(int id) {
        connection = JdbcUtils.getConnection();
        String sql = "delete  FROM t_emp WHERE id = ?";
        try {
            statement = connection.prepareStatement(sql);
            statement.setInt(1, id);
            statement.executeUpdate();

        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.close(connection,statement);
        }
    }
}
